# -*- coding:utf-8 -*-

from typing import List
from datetime import datetime, time
from module_admin.entity.do.role_do import SysRoleDept
from sqlalchemy import and_, delete, desc, func, or_, select, update
from sqlalchemy.ext.asyncio import AsyncSession
from utils.log_util import logger
from module_admin.entity.do.picture_parse_do import PictureParse
from module_admin.entity.vo.picture_parse_vo import PictureParsePageModel, PictureParseModel
from utils.page_util import PageUtil, PageResponseModel

class PictureParseDao:
    @classmethod
    async def add_picture_parses(cls, 
                                          db: AsyncSession, 
                                          add_models: List[PictureParseModel],
                                          auto_commit: bool = True
    ):
        """
        批量增加 PictureParse 实例，处理事务
        """
        picture_parses = [
            PictureParse(**model.model_dump(exclude_unset=True)) 
            for model in add_models
        ]
        db.add_all(picture_parses)
        await db.flush()
        await db.commit()  # 提交事务